package com.atguigu.chaptar7

import scala.util.Random

object $04_MatchType {
  /*
  语法:
        变量 match {
            case x:类型=>{..}
            case x:类型=>{..}
            case x:类型=>{..}
        }
   */
  class Person
  def main(args: Array[String]): Unit = {
    val array = Array("spark", 2, 10.0, false, new Person)
    val i = Random.nextInt(array.length)
    array(i) match {
      case x:String if(x.charAt(0)=='s')=>println("是字符串")
      case _:Int =>println("是Int") //如果_在=>后没使用,可用_
      case _:Double =>println("是Double")
      case _:Boolean =>println("是Boolean")
      case _:Person =>println("是Person")
    }
  }

}
